﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_PETITION
    {
        private string m_Description;
        private string m_EmployeeCode;
        private Guid m_PetitionID;
        private string m_Reason;
        private string m_ReasonCannot;
        private DateTime m_RestFromDate;
        private DateTime m_RestToDate;
        private int m_Status;
        private string m_Symbol;
        private DateTime m_WriteDate;
        private DateTime m_WriteFromDate;
        private DateTime m_WriteToDate;

        public HRM_PROCESS_PETITION()
        {
            this.m_PetitionID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_WriteDate = DateTime.Now;
            this.m_WriteFromDate = DateTime.Now;
            this.m_WriteToDate = DateTime.Now;
            this.m_RestFromDate = DateTime.Now;
            this.m_RestToDate = DateTime.Now;
            this.m_Symbol = "";
            this.m_Reason = "";
            this.m_Status = 0;
            this.m_ReasonCannot = "";
            this.m_Description = "";
        }

        public HRM_PROCESS_PETITION(Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            this.m_PetitionID = PetitionID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_WriteDate = WriteDate;
            this.m_WriteFromDate = WriteFromDate;
            this.m_WriteToDate = WriteToDate;
            this.m_RestFromDate = RestFromDate;
            this.m_RestToDate = RestToDate;
            this.m_Symbol = Symbol;
            this.m_Reason = Reason;
            this.m_Status = Status;
            this.m_ReasonCannot = ReasonCannot;
            this.m_Description = Description;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { this.m_PetitionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Delete", myParams, myValues);
        }

        public string Delete(Guid PetitionID)
        {
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid PetitionID)
        {
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_PETITION_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid PetitionID)
        {
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_PETITION_Delete", myParams, myValues);
        }

        public bool Exist(Guid PetitionID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_RECRUITMENT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid PetitionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_PETITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PetitionID = reader.GetGuid(reader.GetOrdinal("PetitionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_WriteDate = Convert.ToDateTime(reader["WriteDate"]);
                    this.m_WriteFromDate = Convert.ToDateTime(reader["WriteFromDate"]);
                    this.m_WriteToDate = Convert.ToDateTime(reader["WriteToDate"]);
                    this.m_RestFromDate = Convert.ToDateTime(reader["RestFromDate"]);
                    this.m_RestToDate = Convert.ToDateTime(reader["RestToDate"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_ReasonCannot = Convert.ToString(reader["ReasonCannot"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string PetitionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_PETITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PetitionID = reader.GetGuid(reader.GetOrdinal("PetitionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_WriteDate = Convert.ToDateTime(reader["WriteDate"]);
                    this.m_WriteFromDate = Convert.ToDateTime(reader["WriteFromDate"]);
                    this.m_WriteToDate = Convert.ToDateTime(reader["WriteToDate"]);
                    this.m_RestFromDate = Convert.ToDateTime(reader["RestFromDate"]);
                    this.m_RestToDate = Convert.ToDateTime(reader["RestToDate"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_ReasonCannot = Convert.ToString(reader["ReasonCannot"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string PetitionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PetitionID" };
            object[] myValues = new object[] { PetitionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_PETITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PetitionID = reader.GetGuid(reader.GetOrdinal("PetitionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_WriteDate = Convert.ToDateTime(reader["WriteDate"]);
                    this.m_WriteFromDate = Convert.ToDateTime(reader["WriteFromDate"]);
                    this.m_WriteToDate = Convert.ToDateTime(reader["WriteToDate"]);
                    this.m_RestFromDate = Convert.ToDateTime(reader["RestFromDate"]);
                    this.m_RestToDate = Convert.ToDateTime(reader["RestToDate"]);
                    this.m_Symbol = Convert.ToString(reader["Symbol"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_ReasonCannot = Convert.ToString(reader["ReasonCannot"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_PETITION_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_PETITION_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_PETITION_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_PETITION_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_PETITION_GetListByEmployee", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { this.m_PetitionID, this.m_EmployeeCode, this.m_WriteDate, this.m_WriteFromDate, this.m_WriteToDate, this.m_RestFromDate, this.m_RestToDate, this.m_Symbol, this.m_Reason, this.m_Status, this.m_ReasonCannot, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { this.m_PetitionID, this.m_EmployeeCode, this.m_WriteDate, this.m_WriteFromDate, this.m_WriteToDate, this.m_RestFromDate, this.m_RestToDate, this.m_Symbol, this.m_Reason, this.m_Status, this.m_ReasonCannot, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_PETITION_Insert", myParams, myValues);
        }

        public string Insert(Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_PETITION_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_PETITION_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_PETITION", "PetitionID", "TD");
        }

        public void SetData(Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            this.m_PetitionID = PetitionID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_WriteDate = WriteDate;
            this.m_WriteFromDate = WriteFromDate;
            this.m_WriteToDate = WriteToDate;
            this.m_RestFromDate = RestFromDate;
            this.m_RestToDate = RestToDate;
            this.m_Symbol = Symbol;
            this.m_Reason = Reason;
            this.m_Status = Status;
            this.m_ReasonCannot = ReasonCannot;
            this.m_Description = Description;
        }

        public string Update()
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { this.m_PetitionID, this.m_EmployeeCode, this.m_WriteDate, this.m_WriteFromDate, this.m_WriteToDate, this.m_RestFromDate, this.m_RestToDate, this.m_Symbol, this.m_Reason, this.m_Status, this.m_ReasonCannot, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Update", myParams, myValues);
        }

        public string Update(Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_PETITION_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_PETITION_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid PetitionID, string EmployeeCode, DateTime WriteDate, DateTime WriteFromDate, DateTime WriteToDate, DateTime RestFromDate, DateTime RestToDate, string Symbol, string Reason, int Status, string ReasonCannot, string Description)
        {
            string[] myParams = new string[] { "@PetitionID", "@EmployeeCode", "@WriteDate", "@WriteFromDate", "@WriteToDate", "@RestFromDate", "@RestToDate", "@Symbol", "@Reason", "@Status", "@ReasonCannot", "@Description" };
            object[] myValues = new object[] { PetitionID, EmployeeCode, WriteDate, WriteFromDate, WriteToDate, RestFromDate, RestToDate, Symbol, Reason, Status, ReasonCannot, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_PETITION_Update", myParams, myValues);
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Primary Key"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("PetitionID"), Category("Primary Key")]
        public Guid PetitionID
        {
            get
            {
                return this.m_PetitionID;
            }
            set
            {
                this.m_PetitionID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_PETITION";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("Reason"), Category("Column")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [Category("Column"), DisplayName("ReasonCannot")]
        public string ReasonCannot
        {
            get
            {
                return this.m_ReasonCannot;
            }
            set
            {
                this.m_ReasonCannot = value;
            }
        }

        [Category("Column"), DisplayName("RestFromDate")]
        public DateTime RestFromDate
        {
            get
            {
                return this.m_RestFromDate;
            }
            set
            {
                this.m_RestFromDate = value;
            }
        }

        [DisplayName("RestToDate"), Category("Column")]
        public DateTime RestToDate
        {
            get
            {
                return this.m_RestToDate;
            }
            set
            {
                this.m_RestToDate = value;
            }
        }

        [DisplayName("Statis"), Category("Column")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }

        [DisplayName("Symbol"), Category("Column")]
        public string Symbol
        {
            get
            {
                return this.m_Symbol;
            }
            set
            {
                this.m_Symbol = value;
            }
        }

        [DisplayName("WriteDate"), Category("Column")]
        public DateTime WriteDate
        {
            get
            {
                return this.m_WriteDate;
            }
            set
            {
                this.m_WriteDate = value;
            }
        }

        [Category("Column"), DisplayName("WriteFromDate")]
        public DateTime WriteFromDate
        {
            get
            {
                return this.m_WriteFromDate;
            }
            set
            {
                this.m_WriteFromDate = value;
            }
        }

        [DisplayName("WriteToDate"), Category("Column")]
        public DateTime WriteToDate
        {
            get
            {
                return this.m_WriteToDate;
            }
            set
            {
                this.m_WriteToDate = value;
            }
        }
    }
}

